package com.smart.pay.ali.config;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Configuration
public class AliPayConfig {
    @Resource
    AliPayConfigProperties aliPayConfigProperties;

    @PostConstruct
    public void init() {
        Config config = new Config();
        config.protocol = aliPayConfigProperties.getProtocol();
        config.appId = aliPayConfigProperties.getAppId();
        config.merchantPrivateKey = aliPayConfigProperties.getMerchantPrivateKey();
        config.signType = aliPayConfigProperties.getSignType();
        config.alipayPublicKey = aliPayConfigProperties.getAlipayPublicKey();
        config.gatewayHost = aliPayConfigProperties.getGatewayHost();
        config.encryptKey = aliPayConfigProperties.getEncryptKey();
        Factory.setOptions(config);
    }
}
